import time

from numpy import ravel
from sklearn.naive_bayes import GaussianNB
from data import loadDataFromMat
def runGaussianNB(dataName='banana'):
    data=loadDataFromMat(dataName)
    X = data[0]
    y = ravel(data[1])
    num = y.shape[0]
    trainnum = num // 10 * 8
    start = time.clock()
    clf = GaussianNB()
    clf.fit(X[:trainnum], y[:trainnum])
    s = clf.score(X, y)
    end = time.clock()
    return end - start, (1 - s) * 100
# print('GaussianNB',end=',')
# for dataname in ['banana', 'breast_cancer', 'diabetis', 'flare_solar', 'german', 'heart', 'image', 'ringnorm', 'splice', 'thyroid',
#      'titanic', 'twonorm', 'waveform']:
#     runGaussianNB(dataname)

# print("Number of mislabeled points out of a total %d points : %d".format(iris.data.shape[0],(iris.target != y_pred).sum()))